/*
 *   Time Tracking Web Application
 *   Copyright (C) 2008, Nick Griffiths
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *   
 *   Contact nicobrevin at gmail dot com
 *   http://code.google.com/p/openharvest/
 */

package org.brevs.time.manager;

import java.util.Date;
import java.util.List;

import org.appfuse.model.User;
import org.brevs.time.model.Entry;
import org.brevs.time.model.Project;
import org.brevs.time.model.ProjectCategory;

/**
 * Interface for performing operations centered around querying, creating, and 
 * modifying {@link Entry} objects. 
 * @author nick
 */
public interface TimeManager {

	/**
	 * Save an {@link Entry} to the database.
	 * @param entry
	 */
	void saveEntry(Entry entry);

	/**
	 * Returns a list of {@link Entry} objects for a given day and a given
	 * {@link User}.
	 * @param day
	 * @param user
	 * @return
	 */
	List<Entry> getEntries(Date day, User user);

	/**
	 * Start the timer for a given {@link Entry}.  Should automatically stop
	 * any still running {@link Entry} objects.
	 * @param entry
	 */
	void startTiming(Entry entry);

	/**
	 * Stop timing for an {@link Entry}, updating its total seconds in the process.
	 * @param entry
	 */
	void stopTiming(Entry entry);

	/**
	 * Return an {@link Entry} by its primary key.
	 * @param id
	 * @return
	 */
	Entry getEntry(Long id);
	
	/**
	 * Returns a {@link List} of projects that are applicable to a given 
	 * {@link User}.
	 * NOTE: currently returns all projects as no link exists yet between 
	 * users and projects.
	 * @param user
	 * @return
	 */
	List<Project> getProjects(User user);

	/**
	 * Returns a {@link Project} by its primary key.
	 * @param id
	 * @return
	 */
	Project getProject(Long id);
	
	/**
	 * Returns a {@link ProjectCategory} by its primary key.
	 * @param id
	 * @return
	 */
	ProjectCategory getProjectCategory(Long id);
	
	String helloWorld();
	
	/**
	 * Sticks a bunch of dummy objects in to the database, suitable for 
	 * testing.
	 */
	void createDemoData();
	
}
